﻿using MediatR;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Process.Api.Application.Command.BOM;
using Process.DAL;
using Process.ErrorCod;
using Process.Model;

namespace Process.Api.Controllers
{
    /// <summary>
    /// 物品服务
    /// </summary>
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class GoodsController : ControllerBase
    {
        private readonly IMediator mediator;

        public GoodsController(IMediator mediator)
        {
            this.mediator = mediator;
        }
        /// <summary>
        /// 添加
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> AddGoodsinfo(AddGoodsinfoCommand request)
        {
            return await mediator.Send(request);
           
        }
        /// <summary>
        /// 查询物品列表
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public async Task<ApiPageing<Goodsinfo>> GetGoodsinfo([FromQuery]GetGoodsinfoListCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 删除物品数据
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<ApiResult<int>> DeleteGoodsinfo(DeleteGoodsinfoCommand request)
        {
            return await mediator.Send(request);
        }
        /// <summary>
        /// 查询物品详情
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpGet]
        public Task<ApiResult<Goodsinfo>> DetailGoodsinfo([FromQuery]DetailGoodsinfoCommand request)
        {
            return mediator.Send(request);
        }
        /// <summary>
        /// 修改物品信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        /// <exception cref="NotImplementedException"></exception>
        [HttpPost]
        public async Task<ApiResult<int>> UpdateGoodsinfo(UpdateGoodsinfoCommand request)
        {
            return await mediator.Send(request);
        }
       
    }
}
